package com.aaa.service.impl;

import com.aaa.dao.UserDao;
import com.aaa.entity.PageSort;
import com.aaa.entity.User;
import com.aaa.service.UserService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author ：dudu（12232347710@qq.com）
 * @date ：Created in 2022/6/27 10:35
 * @description：
 * @modified By：
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    @Override
    public Page findAllUser(PageSort pageSort) {
        //开始分页
        PageHelper.startPage(pageSort.getPage(), pageSort.getLimit());
        List<User> tblUserList = userDao.findAllUser(pageSort);
        com.github.pagehelper.Page listWithPage = (com.github.pagehelper.Page) tblUserList;
        return listWithPage;
    }

    @Override
    public int addUser(User user) {
        return userDao.addUser(user);
    }

    @Override
    public List<User> findAllName(String userName) {
        return userDao.findAllName(userName);
    }

    @Override
    public int deleteUser(Integer userId) {
        return userDao.deleteUser(userId);
    }

    @Override
    public int updateUser(User user) {
        return userDao.updateUser(user);
    }

    @Override
    public List<Map<String, Object>> findAllUserByName(Map map) {
        return userDao.findAllUserByName(map);
    }

    @Override
    public int resetPwd(User user) {
        return userDao.resetPwd(user);
    }
}
